package main

import (
	"log"
	"net/http"
	"os"
	"path/filepath"
	"service/info"
	"service/utils"
)

func main() {
	dir, err := os.Executable()
	if err != nil {
		log.Fatal("dir no search: ", err)
	}

	exPath := filepath.Dir(dir)

	conf, err := utils.ReadYaml(exPath + "/config.yaml")
	if err != nil {
		log.Fatal("dir no search: ", err)
	}

	log.Println(conf.Server.Port)
	http.HandleFunc("/server_info", info.GetHostInfo) //   设置访问路由
	err = http.ListenAndServe(conf.Server.Port, nil)  //设置监听的端口
	if err != nil {
		log.Fatal("ListenAndServe: ", err)
	}
}
